package com.hns.can.master.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hns.can.common.entity.BaseEntity;
import com.hns.can.master.entity.CommLogFileRcdEntity;
import com.hns.frame.service.CommonService;
import com.hns.tool.pub.PubUtil;

/**
 * 设备文件导入业务类
 * @author:lan
 * @email:763836737@qq.com
 * @version Revision 2.0.0
 */
@Service
public class EqmtFileImpService extends CommonService {
    
    /**
     * 文件已经导入，返回true
     * @param fileName
     * @return
     * @author:lan
     * @email:763836737@qq.com
     */
    @Transactional
    public boolean checkFileIsImp(String fileName){
        boolean result = false;
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("fileName", fileName);
        params.put("fileSt", "1");
        List<CommLogFileRcdEntity> list = commonEntityDao.findByParamsIgnoreNullValue(CommLogFileRcdEntity.class, params);
        if(list.size() > 0){
            result = true;
        }
        return result;
    }
    
    /**
     * 保存到#上传文件日志记录表#
     * @param entity
     * @author:lan
     * @email:763836737@qq.com
     */
    @Transactional
    public void saveLogFileRcdEntity(CommLogFileRcdEntity entity){
        commonEntityDao.save(entity);
    }
    
   /**
    * 动态sql获取通讯表的数据
    * @param object
    * @param paraMap
    * @return
    * @author:lan
    * @email:763836737@qq.com
    */
    @SuppressWarnings({"unchecked", "rawtypes" })
    @Transactional
    public List<BaseEntity> getCommDataBtwRcrdTimes(Class object, Map<String, Object> paraMap) {
        List<BaseEntity> list = PubUtil.convertListMapToObject(
                    this.sqlMapDao.selectList("eqmtFileImp.getCommDataList", paraMap), object);
        return list;
    }
    
}
